package com.itshizhan.viewbindingfragmentdemo

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.itshizhan.viewbindingfragmentdemo.databinding.MainFragmentBinding

class MainFragment:Fragment() {

    private var binding: MainFragmentBinding? = null
    //private val _binding get() = binding!!

    companion object {
        fun newInstance() = MainFragment()
    }

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        binding =  MainFragmentBinding.inflate(inflater,container,false)
        return binding!!.root
       // return _binding.root
    }


    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        binding!!.tv.text = "Hello ViewBinding"
        //_binding.tv.text = "Hello ViewBinding"
    }

    override fun onDestroyView() {
        super.onDestroyView()
        binding = null
    }
}